package com.swak.paxos.breakpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.swak.paxos.Value;

public class ProposerBP {

	private static final Logger logger = LoggerFactory.getLogger(ProposerBP.class);

	public static void newProposal(Value value, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP newProposal value {}, group : {}, instaceID {}.",
				(value == null ? "NULL" : value.getValue()), groupId, instanceID);
	}

	public static void newProposalSkipPrepare(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP newProposalSkipPrepare, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void prepare(int groupId, long instanceID, long proposalID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP prepare, group : {}, instanceID {}, proposalID {}.", groupId, instanceID, proposalID);
	}

	public static void onPrepareReply(int groupId, long instanceID, long proposalID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onPrepareReply, group : {}, instanceID {}, proposalID {}.", groupId, instanceID,
				proposalID);
	}

	public static void onPrepareReplyButNotPreparing(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onPrepareReplyButNotPreparing, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onPrepareReplyNotSameProposalIDMsg(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onPrepareReplyNotSameProposalIDMsg, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void preparePass(int useTimeMs, int groupId, long instanceID, long proposalID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP preparePass useTimeMs {}, group : {}, instanceID {}, proposalID {}. ", useTimeMs,
				groupId, instanceID, proposalID);
	}

	public static void prepareNotPass(int useTimeMs, int groupId, long instanceID, long proposalID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP prepareNotPass useTimeMs {}, group : {}, instanceID {}, proposalID {}.", useTimeMs,
				groupId, instanceID, proposalID);
	}

	public static void accept(int groupId, long instanceID, long proposalID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP accept, group : {}, instanceID {}, proposalID {}.", groupId, instanceID, proposalID);
	}

	public static void onAcceptReply(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onAcceptReply, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onAcceptReplyButNotAccepting(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onAcceptReplyButNotAccepting, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void onAcceptReplyNotSameProposalIDMsg(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP onAcceptReplyNotSameProposalIDMsg, group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void acceptPass(int useTimeMs, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP acceptPass useTimeMs {}, group : {}, instanceID {}.", useTimeMs, groupId, instanceID);
	}

	public static void acceptNotPass(int useTimeMs, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP acceptNotPass useTimeMs {}, group : {}, instanceID {}.", useTimeMs, groupId,
				instanceID);
	}

	public static void proposed(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP proposed group : {}, instanceID {}.", groupId, instanceID);
	}

	public static void prepareTimeout(long timeoutMs, int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP prepareTimeout timeoutMs {}, group : {}, instanceID {}.", timeoutMs, groupId,
				instanceID);
	}

	public static void acceptTimeout(int groupId, long instanceID) {
		if (!logger.isDebugEnabled()) {
			return;
		}
		logger.debug("ProposerBP acceptTimeout, group : {}, instanceID {}.", groupId, instanceID);
	}
}
